<?php

class Aggregator extends Model {

    function find_users($username) {
        $query = "SELECT `users`.*, `photos`.`filename`
                  FROM
                    `users` JOIN `photos`
                  WHERE
                    `users`.`photo_id` = `photos`.`id`
                    AND
                    `users`.`name` LIKE '%$username%'";

        $result = $this->query($query);

        return $result;
    }

    function find_photos($pattern) {
        $query = "SELECT * FROM `photos`
                  WHERE
                    `photos`.`description` LIKE '%$pattern%'
                    OR
                    `photos`.`keywords` LIKE '%$pattern%'
                    OR
                    `photos`.`category` LIKE '%$pattern%'";

        $result = $this->query($query);

        return $result;
    }

}